<template>
  <div style="display: flex;align-items: center;" class="logo">
    <LogoSvg alt="logo" style="width:30px;height: 30px;" />
    <span
      style="color: #FFFFFF;font-size: 24px;margin-left: 12px;font-weight: 700;"
      v-if="showTitle && visibleTitle">{{ this.titles
      }}</span>
  </div>
</template>

<script>
import LogoSvg from '@/assets/logo.svg?inline'
import { mixin, mixinDevice } from '@/utils/mixin'

export default {
  name: 'Logo',
  components: {
    LogoSvg
  },
  mixins: [mixin, mixinDevice],
  data() {
    return {
      titles: '',
      visibleTitle: true
    }
  },
  props: {
    title: {
      type: String,
      default: 'DolphinX',
      required: false
    },
    showTitle: {
      type: Boolean,
      default: true,
      required: false
    }
  },
  methods: {
    hideTitle(hide) {
      this.visibleTitle = !hide
    }
  },
  created() {
    if (this.layoutMode === 'topmenu') {
      if (this.title.length > 8) {
        this.titles = this.title.substring(0, 7) + '...'
      } else {
        this.titles = this.title
      }
    } else {
      if (this.title.length > 10) {
        this.titles = this.title.substring(0, 9) + '...'
      } else {
        this.titles = this.title
      }
    }
  }
}
</script>
